package com.lin.fengxiu.core.configuration;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;

/**
 * @ClassName ExceptionCodeConfiguration
 * @Description  @PropertySource: 关联到配置文件；@ConfigurationProperties:关联到配置项的前缀;@Component：添加到容器中
 * @Author wushaopei
 * @Date 2021/3/6 23:15
 * @Version 1.0
 */

@ConfigurationProperties(prefix = "fengxiu")
@PropertySource(value = "classpath:config/exception-code.properties")
@Component
public class ExceptionCodeConfiguration {

    private Map<Integer, String> codes = new HashMap<>();

    public String getMessage(int code){
        String message = codes.get(code);
        return message;
    }

    public Map<Integer, String> getCodes() {
        return codes;
    }

    public void setCodes(Map<Integer, String> codes) {
        this.codes = codes;
    }
}
